package thread;

public class test23 {
    public static Object locked = new Object();

    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 10; i++) {
            Thread t1 = new Thread(() -> {
                synchronized (locked) {
                    try {
                        locked.wait(100);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.print("A");
                }
            });
            Thread t2 = new Thread(() -> {
                synchronized (locked) {
                    try {
                        locked.wait(200);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.print("B");
                }
            });
            Thread t3 = new Thread(() -> {
                synchronized (locked) {
                    try {
                        locked.wait(300);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.print("C");
                }
            });
            t1.start();
            t2.start();
            t3.start();
            t1.join();
            t2.join();
            t3.join();
            System.out.println();
        }
    }
}
